package project_common

import (
	"github.com/asaskevich/govalidator"
	"log"
	"regexp"
)

func init() {
	log.Println("init validator...")
	govalidator.CustomTypeTagMap.Set("phone", phoneValidator)
}

func phoneValidator(v any, o any) bool {
	phone, ok := v.(string)
	if !ok {
		return false
	}

	regex := regexp.MustCompile(`^\d{11}$`)
	return regex.MatchString(phone)
}
